package com.example.fw;

import org.openqa.selenium.By;

import com.example.tests.ContactData;

public class ContactHelper extends HelperBase{

	public ContactHelper(ApplicationManager manager) {
		super(manager);
	}

	public void submitContactCreate() {
		click(By.name("submit"));
		}

	public void fillContactForm(ContactData contact) {
		type(By.name("firstname"), contact.firstName);
		type(By.name("lastname"), contact.lastName);
		type(By.name("address"), contact.address);
		type(By.name("home"), contact.telHome);
		type(By.name("mobile"), contact.mobile);
		type(By.name("work"), contact.telWork);
		type(By.name("email"), contact.email);
		type(By.name("email2"), contact.email2);
		selectByText(By.name("bday"), contact.bDay);
		selectByText(By.name("bmonth"), contact.bMonth);
		type(By.name("byear"), contact.bYear);
		selectByText(By.name("new_group"), contact.group);
		type(By.name("address2"), contact.address2);
		type(By.name("phone2"), contact.telHome2);
		}

	public void choiceContact(int index) {
		click(By.xpath("//input[@name='selected[]'][" + index + "]"));
	}
	
	public void returnToHomePage() {
		click(By.linkText("home page"));
		}
	
	public void initEditContact() {
		click (By.cssSelector("img[alt=\"Edit\"]"));
	}

	public void deleteContact() {
		click(By.name("update"));
	}
	
	public void updateContact() {
		click(By.name("update"));
	}
	public void searchContact(ContactData contact) {
		findElement(By.name("searchstring"), contact.search);
		}

	

}
